// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	: FI.Net Application Framework
// COMPONENT ID	: FI.Architecture.Server
// COMPONENT DESC:		
//
// CREATED DATE/BY:		18 Aug 2018 / Tian Mi
//
// REVISION HISTORY:	DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

using FI.Core;
using FI.Core.IoC;
using FI.Core.Utilities;

namespace FI.Architecture.Server
{
    /// <summary>
    /// Base class of business component.
    /// </summary>
    public class BusinessComponentBase : ApplicationContextAwareObject, IServiceLocatableObject
    {
        /// <summary>
        /// Gets the service locator.
        /// </summary>
        /// <value>The service locator.</value>
        public IServiceLocator ServiceLocator
        {
            get { return ServiceLocatorFactory.GetServiceLocator(); }
        }
    }

    /// <summary>
    /// Base class of business component.
    /// </summary>
    /// <typeparam name="TDataAccess">The type of the data access.</typeparam>
    public class BusinessComponentBase<TDataAccess> : BusinessComponentBase where TDataAccess : DataAccessBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BusinessComponentBase&lt;TDaObject&gt;"/> class.
        /// </summary>
        /// <param name="da">The da object.</param>
        public BusinessComponentBase(TDataAccess da)
        {
            Guard.ArgumentNotNull(da, "da");
            this.DataAccess = da;
        }

        /// <summary>
        /// Gets or sets the DA object.
        /// </summary>
        /// <value>The DA object.</value>
        public TDataAccess DataAccess { get; private set; }
    }
}